/*
 * bsp_pca9555.c
 *
 *  Created on: 2023年8月28日
 *      Author: fjx
 */
#include "bsp_i2c.h"
#include "app_log.h"
#include "app_gpio_i2c_pca9555.h"


#ifdef PCA9555_DRIVER



#define PCA9555_ADDR                      (0x20<<1)

#define PCA9555_COM_INPUT0                0x00
#define PCA9555_COM_INPUT1                0x01
#define PCA9555_COM_OUTPUT0               0x02
#define PCA9555_COM_OUTPUT1               0x03
#define PCA9555_COM_POLARITY_INV_0        0x04
#define PCA9555_COM_POLARITY_INV_1        0x05
#define PCA9555_COM_CONFIG_0              0x06
#define PCA9555_COM_CONFIG_1              0x07




void pca9555_gpio_config (uint8_t *pdata)
{
  I2C_LeaderWrite(PCA9555_ADDR,PCA9555_COM_CONFIG_0,pdata,2);
}

void pca9555_gpio_out (uint8_t *pdata)
{
  I2C_LeaderWrite(PCA9555_ADDR,PCA9555_COM_OUTPUT0,pdata,2);
}

void pca9555_gpio_polarity_inv (uint8_t *pdata)
{
  I2C_LeaderWrite(PCA9555_ADDR,PCA9555_COM_POLARITY_INV_0,pdata,2);
}
void pca9555_gpio_in (uint8_t *pdata)
{
  I2C_LeaderRead(PCA9555_ADDR,PCA9555_COM_INPUT0,pdata,2);
}

#endif //end of "PCA9555_DRIVER"
